package com.boot.security.server.dao.mffl;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import com.boot.security.server.model.mffl.MfflConsultationlike;

@Mapper
public interface MfflConsultationlikeDao {

    @Select("select * from mffl_consultationlike t where t.id = #{id}")
    MfflConsultationlike getById(Long id);

    @Delete("delete from mffl_consultationlike where id = #{id}")
    int delete(Long id);

    int update(MfflConsultationlike mfflConsultationlike);
    
    @Options(useGeneratedKeys = true, keyProperty = "id")
    @Insert("insert into mffl_consultationlike(userid, consultationid, createTime, updateTime, deletestate, deleteTime,state) values(#{userid}, #{consultationid}, #{createTime}, #{updateTime}, #{deletestate}, #{deleteTime},#{state})")
    int save(MfflConsultationlike mfflConsultationlike);
    
    int count(@Param("params") Map<String, Object> params);

    List<MfflConsultationlike> list(@Param("params") Map<String, Object> params, @Param("offset") Integer offset, @Param("limit") Integer limit);

    //查询用户点赞状态
    @Select("SELECT * FROM `mffl_consultationlike` WHERE userid = #{map.userid} AND consultationid = #{map.consultationid} AND deletestate=1")
    MfflConsultationlike showUserLikeState(@Param("map") Map<String,Integer> map);
}
